Skip to content

fix(qwen3.5-vl): support odd packed lengths without context parallelism - #2544

Open
ActuallyEdward wants to merge 1 commit into
THUDM:mainfrom
ActuallyEdward:edward/fix-qwen35-vl-cp1
Open

ActuallyEdward wants to merge 1 commit into
THUDM:mainfrom
ActuallyEdward:edward/fix-qwen35-vl-cp1

Conversation

@ActuallyEdward

Copy link
Copy Markdown

Qwen3.5-VL training with --context-parallel-size 1 can fail when a packed sequence has an odd token count. The vision-injection path calls get_packed_cp_local_indices() even without a CP split, so boundaries such as [0, 3, 8] raise ValueError: Packed sequence length 3 must be divisible by 2 * CP size 1.

Return the identity token indices at CP=1, where the local stream already is the full packed stream. Preserve empty inputs and the supplied boundary offset. The two-chunk mapping and divisibility checks for CP>1 remain unchanged.

This follows up on #2376, which was closed without merging. Credit to @shifangx for the original report and call-site fix, and @augustuszzq for documenting the helper-side alternative and reproduction in this comment. This PR uses the helper-side fix with CPU regression coverage; the Qwen call site remains affected on upstream 79aa41a884ab0bf65222c94418f6357d3c31192b.

Validation

CUDA_VISIBLE_DEVICES='' PYTHONPATH=. PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 \
  python -m pytest -o addopts='' -q tests/test_qwen3_5_vl_native.py
  • Upstream helper with the updated tests: 8 failed, 19 passed. All failures are odd-length CP=1 cases.
  • With the fix: 27 passed on CPU, using Python 3.12.13 and PyTorch 2.11.0+cu129.
  • Coverage includes list/tensor boundaries, odd/even lengths, empty sequences/inputs, nonzero boundary offsets, every rank at CP=2/4, and rejection of indivisible sequences at CP>1.
  • Black, isort, Ruff, and git diff --check passed. The test module is already registered in the CPU CI matrix.

Validation is limited to CPU tests; a new GPU or distributed training run was not performed for this PR.

AI assistance: OpenAI Codex assisted with implementation, validation, and this description.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant